class Solution
{
public:
    string greatestLetter(string s)
    {
        vector<int> flag(26, 0);
        for (char c : s)
        {
            if ('a' <= c && c <= 'z')
            {
                flag[c - 'a'] |= 1;
            }
            else if ('A' <= c && c <= 'Z')
            {
                flag[c - 'A'] |= 2;
            }
        }
        for (int i = 25; i >= 0; --i)
        {
            if (flag[i] == 3)
            {
                return {static_cast<char>('A' + i)};
            }
        }
        return "";
    }
};